﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin DauSach
    /// --DAUSACH(MaDauSach,TenDauSach,MaTheLoai)
    /// </summary>
    public class DauSach : BusinessObjects
    {
        public DauSach()
        {
            MaDauSach = Int16.MaxValue;
            TenDauSach = null;
            MaTheLoai = Int16.MaxValue;
        }

        public DauSach(int _maDS, string _tenDS, int _maTL)
        {
            MaDauSach = _maDS;
            MaTheLoai = _maTL;
            TenDauSach = _tenDS;
        }

        public void SetParameterSelectID()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDauSach, MaDauSach);
            parms[0] = _parm;
        }

        public override void SetParameterInsert()
        {
            parms = new object[3];
            SqlParameter _parm = new SqlParameter(parTenDauSach, TenDauSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaTheLoai, MaTheLoai);
            parms[1] = _parm;

            _parm = new SqlParameter();
            _parm.ParameterName = parMaDauSach;
            _parm.SqlDbType = SqlDbType.Int;
            _parm.Direction = ParameterDirection.Output;
            parms[2] = _parm;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[3];
            SqlParameter _parm = new SqlParameter(parMaDauSach, MaDauSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parTenDauSach, TenDauSach);
            parms[1] = _parm;

            _parm = new SqlParameter(parMaTheLoai, MaTheLoai);
            parms[3] = _parm;
        }

        public void SetParameterDelete()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDauSach, MaDauSach);
            parms[0] = _parm;
        }

        public int MaDauSach { get; set; }
        private const string parMaDauSach = "@MaDauSach";

        public string TenDauSach { get; set; }
        private const string parTenDauSach = "@TenDauSach";

        public int MaTheLoai { get; set; }
        private const string parMaTheLoai = "@MaTheLoai";
    }
}
